package com.why.blog.service.impl;

import com.why.blog.dao.mapper.HaloPostsTagsMapper;
import com.why.blog.dao.mapper.HaloTagMapper;
import com.why.blog.entity.HaloTag;
import com.why.blog.entity.VO.TagVo;
import com.why.blog.service.TagService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author TriggerWu
 * @since 2019-04-28
 */
@Service
public class HaloTagServiceImpl implements TagService {

    @Autowired
    private HaloTagMapper tagMapper;

    @Autowired
    private HaloPostsTagsMapper postsTagsMapper;

    @Override
    public Integer insertrecord(HaloTag tag) {
        return tagMapper.insertrecord(tag);
    }

    @Override
    public List<TagVo> selectTags(String postId) {
        if (StringUtils.isBlank(postId)) {
            return null;
        }
        return postsTagsMapper.selectTags(postId);
    }

    @Override
    public List<TagVo> tagCloud() {
        return postsTagsMapper.tagsCloud();
    }
}
